Page History: Processing Chart Data
Compare Page Revisions
Page Revision: 2012/01/23 12:25
The IChartDataRequest.Data property contains the data retrieved from the chart data servers. This property will not contain valid data until the request is fully completed (as evidenced by the callback being called.)
Before processing the chart data, you should check the Status property to make sure the request was successful. A status of Failed means that the request was unable to retrieve chart data for some reason. The StatusMessage property may give more information about the failure depending on the failure reason. A status of Completed means the chart data request completed successfully and the data is ready to be used.
IChartDataRequset.Data returns an object of type
Market.BarData which contains the chart data retrieved from the servers. This data is accessed by enumerating the bars with calls to the MarketBarData.Read method in a similar way to reading a database resultset. The Read method will return True if additional data is available, and False if the end of the data has been reached.
Following a call to Read, the Change property must be checked to see which data is actually available (e.g. which properties you should read next.)
The Change property will return a ChartDataChange value with one of the values described
here.
Example:
Private Sub moMarket_MarketBarData(ByVal poMarket As T4.API.Market, ByVal poBarData As T4.API.Market.BarData) Handles moMarket.MarketBarData
Trace.WriteLine(String.Format("moMarket_MarketBarData: {0}, {1}, {2}", poBarData.MarketID, poBarData.StartTime, poBarData.EndTime))
Do While poBarData.Read
Select Case poBarData.Change
Case ChartDataChange.MarketMode
Trace.WriteLine(String.Format("Time: {0}, Mode: {1}", poBarData.Time, poBarData.Mode))
Case ChartDataChange.Settlement
Trace.WriteLine(String.Format("Time: {0}, Settlement: {1}", poBarData.Time, poBarData.SettlementPrice))
Case ChartDataChange.TradeBar
Trace.WriteLine(String.Format("Time: {5}, Open: {0}, High: {1}, Low: {2}, Close: {3}, Volume: {4}", poBarData.OpenPrice, poBarData.HighPrice, poBarData.LowPrice, poBarData.ClosePrice, poBarData.BarVolume, poBarData.BarStartTime))
End Select
Loop
End Sub
The following table summarizes which properties of the MarketChartData object are valid for a given Change value: